package org.dlow.tolerant;

import org.dlow.common.constants.FaultTolerant;
import org.dlow.spi.ExtensionLoader;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @Author: 山沐与山
 * @CreateTime: 2024-05-16 23:22
 */
public class FailureHandlerFactory {


    public static FailureHandler get(FaultTolerant faultTolerant){
        final String name = faultTolerant.name;
        return ExtensionLoader.getInstance().get(name);
    }

    public static FailureHandler get(String name){
        return ExtensionLoader.getInstance().get(name);
    }

    public static void init() throws IOException, ClassNotFoundException {
        final ExtensionLoader extensionLoader = ExtensionLoader.getInstance();
        ExtensionLoader.getInstance().loadExtension(FailureHandler.class);
    }
}
